package com.cc2019.buke.type.frag;

import android.content.Context;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.cc2019.buke.R;
import com.cc2019.buke.type.adapter.ChinaTypeAdapter;
import com.cc2019.buke.type.adapter.WaiguoTypeAdapter;
import com.cc2019.buke.type.entry.TypeC;
import com.cc2019.buke.type.entry.TypeW;

import java.util.ArrayList;
import java.util.List;

public class TypeCFragment extends Fragment{
    private RecyclerView recyclerView;
    private View view;
    private Context context;
    private ChinaTypeAdapter adapter;
    private static final int REFRESH = 0;
    private static final int LOADING = 1;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view =inflater.inflate(R.layout.fragment_type_c, container, false);

        recyclerView = view.findViewById(R.id.my_RecyViewC);
        context = this.getContext();

        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Context context = this.getContext();
        List<TypeC> typec_list = init();
        GridLayoutManager gridLayoutManager = new GridLayoutManager(context,3);
        recyclerView.setLayoutManager(gridLayoutManager);
        adapter=new ChinaTypeAdapter(typec_list,context);
        recyclerView.setAdapter(adapter);
    }

    public List<TypeC> init() {
        ArrayList<TypeC> pros = new ArrayList<>();
        TypeC typeC = new TypeC();
        TypeC typeC1=new TypeC(R.drawable.c5,"城南旧事");
        TypeC typeC2=new TypeC(R.drawable.c6,"红楼梦");
        TypeC typeC3=new TypeC(R.drawable.c7,"活着");
        TypeC typeC4=new TypeC(R.drawable.c8,"狂人日记");
        TypeC typeC5=new TypeC(R.drawable.c9,"骆驼祥子");
        TypeC typeC6=new TypeC(R.drawable.c10,"呐喊");
        TypeC typeC7=new TypeC(R.drawable.c11,"三国演义");
        TypeC typeC8=new TypeC(R.drawable.c12,"四世同堂");
        TypeC typeC9=new TypeC(R.drawable.c13,"隋唐演义");
        TypeC typeC10=new TypeC(R.drawable.c14,"我们仨");
        TypeC typeC11=new TypeC(R.drawable.c15,"西游记");
        TypeC typeC12=new TypeC(R.drawable.c16,"朝花夕拾");
        TypeC typeC13=new TypeC(R.drawable.c17,"在细雨中呼喊");
        TypeC typeC14=new TypeC(R.drawable.c18,"繁华落尽是孤独");
        TypeC typeC15=new TypeC(R.drawable.c19,"园林晓月远行人");
        TypeC typeC16=new TypeC(R.drawable.c20,"季羡林自传");
        TypeC typeC17=new TypeC(R.drawable.c21,"恰到好处的幸福");
        TypeC typeC18=new TypeC(R.drawable.c22,"切开忧郁的洋葱");
        TypeC typeC19=new TypeC(R.drawable.c23,"秋");
        TypeC typeC20=new TypeC(R.drawable.c24,"巴金");
        TypeC typeC21=new TypeC(R.drawable.c25,"你是人间四月天");
        TypeC typeC22=new TypeC(R.drawable.c26,"阿Q正传");
        TypeC typeC23=new TypeC(R.drawable.c27,"爱上一座城");
        TypeC typeC24=new TypeC(R.drawable.c28,"茶馆");
        pros.add(typeC1);pros.add(typeC2);pros.add(typeC3);pros.add(typeC4);pros.add(typeC5);pros.add(typeC6);pros.add(typeC7);
        pros.add(typeC8);pros.add(typeC9);pros.add(typeC10);pros.add(typeC11);pros.add(typeC12);pros.add(typeC13);
        pros.add(typeC14);pros.add(typeC15);pros.add(typeC16);pros.add(typeC17);pros.add(typeC18);
        pros.add(typeC19);pros.add(typeC20);pros.add(typeC21);pros.add(typeC22);
        pros.add(typeC23);pros.add(typeC24);
        return pros;
    }

}